<template>
	<view class="p10">
		<view class="flex" style="border-bottom: 1px solid gainsboro;
    height: 50px;">
			<view class="size-24">
				对外隐藏拥有的藏品
			</view>
			<u-switch size="40" v-model="checkedone" @change="change"></u-switch>
		</view>
		<view class="flex mt-30" style="    border-bottom: 1px solid gainsboro;
    height: 50px;">
			<view class="size-24">
				对外隐藏卖出的藏品
			</view>
			<u-switch size="40" v-model="checkedtwo" @change="change1"></u-switch>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				checkedone: '',
				checkedtwo: '',
				privacy_have:'',
				privacy_sell:''
			}
		},
		onLoad(){
			this.init()
		},
		methods:{
			change(e) {
			if(e==true){
				this.privacy_have=1
			}else{
				this.privacy_have=0
			}
				this.$http('api/user/edit_privacy',{
					privacy_have:this.privacy_have,
					privacy_sell:this.privacy_sell,
					}).then(res => {
				});
			},
			change1(e){
				if(e==true){
					this.privacy_sell=1
				}else{
					this.privacy_sell=0
				}
				this.$http('api/user/edit_privacy',{
					privacy_have:this.privacy_have,
					privacy_sell:this.privacy_sell,
					}).then(res => {
				});
			},
			init(){
				this.$http('api/user/privacy').then(res => {
					console.log(res.privacy_have)
					console.log(res.privacy_sell)
					if(res.privacy_have==1){
						this.checkedone=true
						this.privacy_have=1
					}else{
						this.checkedone=false
						this.privacy_have=0
					}
					if(res.privacy_sell==1){
						this.checkedtwo=true
						this.privacy_sell=1
					}else{
						this.checkedtwo=false
						this.privacy_sell=0
					}
				});
			}
		},
	}
</script>

<style>
</style>
